<?php /*a:3:{s:48:"D:\www\long_shop\app\view\dept\school_check.html";i:1726834504;s:42:"D:\www\long_shop\app\view\common\head.html";i:1702389678;s:48:"D:\www\long_shop\app\view\common\pagination.html";i:1702389678;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/jquery/jquery-1.12.4.min.js"></script>    
    <link href="/static/bst5.3.2/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/bst5.3.2/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="/static/bst-icons/font/bootstrap-icons.css">
    <script src="/static/layer/layer/layer.js"></script>
    <link rel="stylesheet" href="/static/css/my.css">    
</head>
<head>
    <title>商家管理</title>
    <style>
        a{text-decoration:none;}
        input{display:initial!important;}
  
    </style>
</head>
<body >
<div class="container-fluid " style="margin: 10px;">

    <form action="/index.php/dept/check" method="post">
        <div class="row" id="query_bar" style="height: 50px;line-height: 50px;">
            <div class="col-2" style="text-align: left;line-height: 50px;font-size: 2rem;" >
                <?php if($status>1): ?><h2>商家入驻审核</h2>
                <?php else: ?><h2>商家管理</h2><?php endif; ?>
            </div>
            <div class="col-10">
            <label for="status" >状态：</label>
            <select name="status" class="form-control" style="width:140px;display:initial;">
                <option value="" <?php if($status==''): ?> selected <?php endif; ?>>所有</option>
                <option value="1" <?php if($status==1): ?> selected <?php endif; ?>>正常</option>
                <option value="3" <?php if($status==3): ?> selected <?php endif; ?>>待审</option>
                <option value="4" <?php if($status==4): ?> selected <?php endif; ?>>已驳回</option>
            </select>

            <label for="name" >商家名称：</label>
            <input class="form-control" type="text"  id="name" name="name" value="<?php echo htmlentities($name); ?>"  />

            <button type="button" class="btn btn-warning query" style="vertical-align: middle;" >
                <span class="bi-search" ></span>
            </button>
        
            </div>

        </div>
    </form>

    
    <table class="table table-sm table-hover table-striped">
        <thead>
            <th>序号</th>
            <th>名称</th>
            <th>地区/地址</th>
            <th>负责人</th>
            <th>身份证照</th>            
            <th>联系电话</th>
            <!-- <th>社会代号</th> -->
            <th>营业执照</th>
            <th>门头照</th>
            <th>轮播图</th>
            <th>提交日期</th>            
            <th>审核时间</th>
            <th>状态</th>
            <th>

            </th>
        </thead>
        <tbody>
            <?php foreach($list['data'] as $k=>$kv): ?>
            <tr >
                <td><?php echo htmlentities($k+1); ?></td>
                <td><?php echo htmlentities($kv['name']); ?></td>
                <td><?php echo htmlentities($kv['city']); ?><br /><?php echo htmlentities($kv['address']); ?></td>
                <td><?php echo htmlentities($kv['boss_name']); ?></td>
                <td>
                    <?php foreach($kv['id_img'] as $img): ?>
                        <img src="<?php echo htmlentities($img); ?>" class="goods_image" style="width:50px;" />
                    <?php endforeach; ?>
                </td>                        
                <td><?php echo htmlentities($kv['mobile']); ?></td>
                <!-- <td><?php echo htmlentities($kv['credit_code']); ?></td> -->
                <td><img src="<?php echo htmlentities($kv['bus_license_img']); ?>" class="goods_image" style="width:50px;" /></td>
                <td><img src="<?php echo htmlentities($kv['shop_img']); ?>" class="goods_image" style="width:50px;" /></td>
                <td>
                    <?php foreach($kv['ad_img'] as $img): ?>
                        <img src="<?php echo htmlentities($img); ?>" class="goods_image" style="width:50px;" />
                    <?php endforeach; ?>
                </td>
                <td><?php echo htmlentities($kv['create_time']); ?></td>
                <td><?php echo htmlentities($kv['check_time']); ?></td>
                <td><?php echo htmlentities($kv['status_name']); ?></td>
                <td>
                    <?php if($kv['status']>1): ?>
                    <button style="button" class="btn btn-sm btn-info" dept_id="<?php echo htmlentities($kv['id']); ?>" title="通过审核">
                        <span class="bi-check">通过</span>
                    </button>
                    <button style="button" class="btn btn-sm btn-warning" dept_id="<?php echo htmlentities($kv['id']); ?>"　title="驳回审核">
                        <span class="bi-dash">驳回</span>
                    </button>
                    
                    <?php endif; ?>

                    <a href="/index.php/dept/edit/id/<?php echo htmlentities($kv['dept_id']); ?>">
                        <button style="button" class="btn btn-sm btn-primary" dept_id="<?php echo htmlentities($kv['id']); ?>"　title="编辑">
                            <span class="bi-pencil btn-edit"></span>
                        </button>
                    </a>

                </td>
            </tr>
            <?php endforeach; ?>

        </tbody>    
    </table>          <ul class="pagination pagination" >

        <?php if($list['current_page']>1): ?>
            <li class="page-item">
                <a class="page-link" href="?page=1<?php if(!empty($query)): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-double-left"></span>
                </a>
            </li>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo htmlentities($list['current_page']-1); if(!empty($query)): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-left"></span>
                </a>
            </li>
        <?php endif; ?>

        <li class="page-item">
            <c class="page-link text-secondary"><?php echo htmlentities($list['current_page']); ?>/<?php echo htmlentities($list['last_page']); ?></c>
        </li>

        <?php if($list['current_page']<$list['last_page']): ?>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo htmlentities($list['current_page']+1); if(!empty($query) && $query!=''): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-right"></span>    <!--下一页-->
                </a>
            </li>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo htmlentities($list['last_page']); if(!empty($query)): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-double-right"></span>    <!--末页-->
                </a>
            </li>
        <?php endif; ?>


      </ul>
      <br/>
      
</div>


</body>

<script type="text/javascript">

    $(function(){
        $(".query").on('click',function(){
            var index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2

            $("form").submit();
            layer.close(index);
        }) 

        $(".btn-info").on('click',function(){
            console.log(1);
            check_pass($(this).attr('dept_id'),1);
        })
        $(".btn-warning").on('click',function(){
            console.log(3);
            check_pass($(this).attr('dept_id'),4);
        })

        $(".goods_image").on('click',function(){
            var img = $(this).attr('src');
            if(!img.trim()) return;

            layer.open({
              type: 1,
              title:'',
              closeBtn: 0, //不显示关闭按钮
             // anim: 1,
              time: 5*1000,
              shadeClose: true, //开启遮罩关闭              
              skin: 'layui-layer-rim', 
              content: "<img src='"+img+"' style='height:100%'>"
            });
        })        
    });



    function check_pass(dept_id,status){
        if(!dept_id) return false;
        var msg=status==1?'通过':'驳回';
        console.log(status);
        var reject_msg ='';

        if(status==4){
            layer.prompt({
                formType: 2,
                value: '',
                title: '请输入驳回理由',
                area: ['400px', '350px'] //自定义文本域宽高
            }, function(value, index, elem){
                reject_msg =value; //得到value
                layer.close(index);
                var data={id:dept_id,status:status,reject_msg:reject_msg};
                console.log(reject_msg);
                apost(data,msg);
            });
        }

        var data={id:dept_id,status:status,reject_msg:reject_msg};
        if(status==1) apost(data,msg);
  
    }

    function apost(data,msg){
        layer.confirm('注意：通过之前请仔细检查相关资料！<br/>是否确定【'+msg+'】驾校入驻?',{btn: ['确定'+msg,'再检查一下']},function(){
            $.post("/index.php/dept/check",data,function(res){
                console.log(res);
                    layer.msg(res.msg);
                    if(res.code==1){
                    window.location.reload();
                    }
                });
        }, function(){
            layer.msg("Cancel!");
            return 0;
        });
    }



</script>


</body>
</html>
